window.onload = function () {
    var leftBtn = document.getElementById("leftBtn");
    var yuanRight = document.getElementById("rightBtn");
    var lrTranslate = document.getElementById("lrTranslate");
    var itemImgBox = document.getElementsByClassName("itemImgBox");
    if (itemImgBox.length > 4) {
        var slideLength = (itemImgBox.length - 4) * 251;
        var i = 0;
        var z = 251;
        leftBtn.onclick = function () {
            if (i > -slideLength) {
                yuanRight.innerHTML = ">";
                yuanRight.style.lineHeight = "42px";
                yuanRight.style.fontSize = "45px";
                yuanRight.style.paddingLeft = "5px";
                yuanRight.style.cursor = "pointer";
                i = i - z;
                lrTranslate.style.transform = "translate(" + i + "px)";
                if (i == -slideLength) {
                    leftBtn.innerHTML = "一";
                    leftBtn.style.lineHeight = "47px";
                    leftBtn.style.fontSize = "33px";
                    leftBtn.style.paddingRight = "0";
                    leftBtn.style.cursor = "default"
                }
            }
        };
        yuanRight.onclick = function () {
            if (i < 0) {
                leftBtn.innerHTML = "<";
                leftBtn.style.lineHeight = "42px";
                leftBtn.style.fontSize = "45px";
                leftBtn.style.paddingRight = "5px";
                leftBtn.style.cursor = "pointer";
                i = i + z;
                lrTranslate.style.transform = "translate(" + i + "px)";
                console.log(i);
                if (i == 0) {
                    yuanRight.innerHTML = "一";
                    yuanRight.style.lineHeight = "47px";
                    yuanRight.style.fontSize = "33px";
                    yuanRight.style.paddingLeft = "0";
                    yuanRight.style.cursor = "default"
                }
            }
        };
    } else {
        leftBtn.style.display = "none";
        yuanRight.style.display = "none"
    }
};


